<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../Template/TemplateAccount.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">

    <ui:define name="content">
        <p:fieldset legend="LIST OF CATEGORY">
            <f:view>
                <h:form id="form">
                    <p:dataTable id="dataTable" value="#{categoryBean.all}" var="category" selectionMode="single" selection="#{categoryBean.selectCategory}"
                                 rowKey="#{category.categoryID}"  style="width: 100% ;font-size:10px;font-weight: 10px"
                                 paginator="true" rows="10" 
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
                                 rowsPerPageTemplate="5,10,15">
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="STT"/>
                            </f:facet>
                            <h:outputText value="#{category.categoryID}"/>
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Name"/>
                            </f:facet>
                            <h:outputText value="#{category.categoryName}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">Symbol</f:facet>
                            <h:outputText value="#{category.symbol}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">Solution</f:facet>
                            <h:outputText value="#{category.solution}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">Description</f:facet>
                            <h:outputText value="#{category.description}"/>
                        </p:column>
                        <f:facet name="footer">
                            <p:commandButton id="viewButton" value="Create"  action="#{categoryBean.createComplaint()}"
                                             oncomplete="dialogCate.show()"/>
                        </f:facet>
                    </p:dataTable>



                </h:form>
                <p:dialog widgetVar="dialogCate" resizable="true" showEffect="clip" hideEffect="fold" id="complaintDialog">
                    <h:form>
                        <p:panelGrid columns="2" style="width: 800px; border:none ">
                            <f:facet name="header">  
                                CREATE COMPLAINT  
                            </f:facet>
                            <p:outputLabel value="Category Name" for="category"/>
                            <p:selectOneMenu id="category" value="#{categoryBean.newComplaint.categoryID.categoryID}">
                                <f:selectItems value="#{categoryBean.category}"/>
                            </p:selectOneMenu>
                            <p:outputLabel value="Subject" for="category"/>
                            <p:inputText style="width: 345px" value="#{categoryBean.newComplaint.note}"/>
                            <p:outputLabel value="Content" for="category"/>
                            <p:inputText style="width: 345px" value="#{categoryBean.newComplaint.description}"/>
                            <h:inputSecret style="width: 345px" value="#{categoryBean.passWord}"/> 
                            <f:facet name="footer">
                                <p:commandButton id="create" value="Create"  action="#{categoryBean.create()}"
                                                 update=":form:dataTable" oncomplete="dialogCate.hide()" />
                            </f:facet>
                        </p:panelGrid>
                    </h:form>

                </p:dialog>
            </f:view>
        </p:fieldset>
    </ui:define>

</ui:composition>
